<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<title><?php echo ($name); ?></title>
<script src="__APP__/statics/jquery-1.9.1.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="__APP__/statics/css/jNotify.jquery.css" />
<script type="text/javascript" src="__APP__/statics/jNotify.jquery.js"></script>
<style>
 body{font-family:"微软雅黑";font-size:12px;color:#666666;background-color:#F9F9F6}
 *{margin: 0;} 
 a{text-decoration:none}
 img{border:0px}
.cat{background-color:#F9F9F6;margin-left:10px;z-index:0;}
.cat_list:hover{background-color:#fff;}
.title{background:url("__APP__/statics/tbg.gif");font-weight:bold}

#save{text-align:center;border:0;width:100%;height:40px;background-color:#fff;position:fixed;left:0px;bottom:0px;z-index:999;border:1px solid #DFDFDF;background-color:#DFDFDF;padding:5px;height:20px}
</style>

<style>
#ad_pic img{max-width:100px;}
</style>
<form method="post" action="__URL__/save_sort">
<table bordercolor="#DDDFFF" border="1" width="100%" style="border-collapse: collapse" cellpadding="3">
	<tr height="17" align="center">
	    <td class="title" width="80">排序</td>
		<td class="title" width="80">广告类型</td>
		<td class="title" width="150">内容</td>
		<td class="title" width="200">链接</td>
		<td class="title" width="110">添加时间</td>
		<td class="title" width="110">失效时间</td>
		<td class="title" width="40">显示</td>
		<td class="title" width="40">删除</td>
		<td class="title">　</td>
	</tr>
<?php if(is_array($adlist)): $i = 0; $__LIST__ = $adlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$adlist): $mod = ($i % 2 );++$i;?><tr height="20" bgcolor="#F1F5FA" class="cat_list">
	    <td width="80" align="center">
		    <input type="text" name="adid[]" value="<?php echo ($adlist["ad_id"]); ?>" style="display:none">
			<input type="text" name="sorting[]" size="4" value="<?php echo ($adlist["sorting"]); ?>">
		</td>
<!--根据广告类型显示-->
<?php switch($adlist["type"]): case "1": ?><td width="80" align="center">文字</td>
		<td width="150"><?php echo ($adlist["content"]); ?></td>
		<td width="200">无</td><?php break;?>
	<?php case "2": ?><td width="80" align="center">图片</td>
		<td width="150" align="center" id="ad_pic"><img src="__APP__/<?php echo ($adlist["file"]); ?>" height="50" onmouseover="get_pic('<?php echo ($adlist["file"]); ?>')" onmouseout="hid_pic()"></td>
		<td width="200"><input type="text" name="url[]" value="<?php echo ($adlist["path_url"]); ?>" size="30"></td><?php break;?>
	<?php case "3": ?><td width="80" align="center">flash</td>
		<td width="150"><?php echo ($adlist["place_name"]); ?></td>
		<td width="200"><input type="text" name="url[]" value="<?php echo ($adlist["path_url"]); ?>" size="30"></td><?php break;?>
	<?php case "4": ?><td width="80" align="center">代码</td>
		<td width="150"><?php echo ($adlist["place_name"]); ?></td>
		<td width="200">无</td><?php break; endswitch;?>
		<td width="110"><?php echo (date("Y/m/d H:i",$adlist["add_time"])); ?></td>
		<td width="110"><?php echo (date("Y/m/d H:i",$adlist["end_time"])); ?></td>
		<td width="40" align="center" id="is_show">
<?php if($adlist["is_show"] == 'true'): ?><img alt="显示中" src="__APP__/statics/infosuccess.gif" height="15" onclick="to_hidden(<?php echo ($adlist["ad_id"]); ?>)"/>
<?php else: ?>
        <img alt="不显示" src="__APP__/statics/infoerror.gif" height="15" onclick="to_show(<?php echo ($adlist["ad_id"]); ?>)"/><?php endif; ?>
		</td>
		<td width="40" align="center"><a href="javascript:;" onclick="deletes(<?php echo ($adlist["ad_id"]); ?>)"><img alt="删除" src="__APP__/statics/icons/icon_delete.gif"></a></td>
		<td></td>
	</tr><?php endforeach; endif; else: echo "" ;endif; ?>
</table>
<br></br>
<div id="bigpic" style="position:fixed;display:none;top:0px"></div>
<div id="save"><input type="submit" style="padding:2px" value="保存更改"></div>
</form>
<script>
function deletes(t){
    var gid=t;
	if(confirm('你确认删除此广告吗？')) {
       $.ajax({
	       type:"GET",
		   url:"__URL__/remove",
		   dataType:"json",
		   data:{"ad_id":gid},
		   success:function(data){
               if(data=='1'){
				   jSuccess("<strong>删除成功！</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}})
			  }else{
			      jError("<strong>删除失败!请重试</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
			 }
		   }
	   })

	}
}

function to_hidden(t){
    $.ajax({
	       type:"GET",
		   url:"__URL__/change_show",
		   dataType:"html",
		   data:{"action":"hidden","ad_id":t},
		   success:function(data){
		   jSuccess("<strong>更改成功！</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}})
		   }
	})
}

function to_show(t){
    $.ajax({
	       type:"GET",
		   url:"__URL__/change_show",
		   dataType:"html",
		   data:{"action":"show","ad_id":t},
		   success:function(data){
		   jSuccess("<strong>更改成功！</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}})
		   }
	})
}

function get_pic(t){
$("#bigpic").css("display","block");
var pic="<img src='__APP__/"+t+"'>";
$("#bigpic").html(pic);
}

function hid_pic(){
$("#bigpic").css("display","none");
}
</script>
<script src="__APP__/statics/webox/webox.js"></script>
<link href="__APP__/statics/webox/jquery-webox.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function add(){
		$.webox({
		    scroll:'no',
			height:465,
			width:950,
			bgvisibel:true,
			title:'添加广告位',
			iframe:'__URL__/add/'+Math.random
		});
}
function edit(t){
       var gid=t;
		$.webox({
		    scroll:'no',
			height:465,
			width:950,
			bgvisibel:true,
			title:'修改全局变量',
			iframe:'__URL__/edit/?gid='+gid
		});
}
</script>